<div class="panel-admin panel-base">	
	<div class="row-fluid">
		<div class="span6">			
			<h1>List of member</h1>
			<p>รายการสมาชิกทั้งหมด</p>
		</div>
		<div class="span6 text-right">
			<form class="form-search">
			  <input type="text" class="input-medium search-query">
			  <button type="submit" class="btn">Search</button>
			</form>
		</div>
	</div>
	
		<div class="panel-admin-inner">		
			
			<table class="table table-hover table-member">
				<thead>
					<tr>
						<th style="width:5%;"></th>
						<th style="width:10%"></th>
						<th style="width:50%;">ชื่อสมาชิก</th>
						<th style="width:25%;">ชื่อผู้ใช้</th>
						<th style="width:10%;"></th>
					</tr>
				</thead>
				<tbody>			
					<?php
						if (count($member_list) > 0){
							for ($i=0; $i<count($member_list); $i++){ ?>
								<tr>
									<td><input type="checkbox" name="chk-c" value="<?php print $member_list[$i]['MEM_ID']; ?>" /></td>
									<td><img class="img-rounded" src="<?php print $member_list[$i]['MEM_AVATAR']; ?>" width="40" height="40" /></td>
									<td><?php print $member_list[$i]['MEM_TITLE']; ?></td>
									<td><?php print $member_list[$i]['MEM_EMAIL']; ?></td>
									<td>
										<div class="btn-group">
											<button class="btn dropdown-toggle" data-toggle="dropdown">Action <span class="caret"></span></button>
							                <ul class="dropdown-menu">
							                	<li><a href="<?php print base_url() ?>admin/member/view?m=<?php print $member_list[$i]['MEM_ID']; ?>" target="_blank">ดูข้อมูล</a></li>							                	
												<li><a class="btn-remove btn-danger" href="#" data-value="<?php print $member_list[$i]['MEM_ID']; ?>">ลบข้อมูล</a></li>							                  
											</ul>
										</div>
									</td> 
								</tr>							
							<?php }
						} 
					?>
				</tbody>
			</table>					
		</div>
	
	
		<div class="pagination">
		  <ul>
		    <li><a href="<?php print base_url() . 'admin/member/list?s=1'; ?>">First</a></li>    
		    <?php for ($i=0; $i<$page_count; $i++) {?>
		      	<li><a href="<?php print base_url() . 'admin/member/list?s=' . ($i+1); ?>"><?php print $i+1; ?></a></li>
		    <?php }?>
		    <li><a href="<?php print base_url() . 'admin/member/list?s=' . $page_count; ?>">Last</a></li>
		  </ul>
		</div>
	
</div>
 
<!-- Remove Item Modal -->
<div id="modal-remove-item" class="modal hide fade" role="dialog" aria-hidden="true">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		<h3>ยืนยันการลบร้าน</h3>
	</div>
	<div class="modal-body">
		<p>ยืนยันการลบร้าน</p>
	</div>
	<div class="modal-footer">
		<button class="btn" data-dismiss="modal" aria-hidden="true">ยกเลิก</button>
		<button class="btn btn-primary" id="btn-remove-submit">ตกลง</button>
	</div>
</div>

<script type="text/javascript">
	var row, c;
	$('.btn-enable, .btn-disable, .btn-remove').click(function(){
		$('#modal-remove-item').modal('show');

		row = $(this).parents('tr');
		c = $(this).attr('data-value');	
	});

	$('#btn-remove-submit').on('click', function(){
		$.post('<?php print base_url(); ?>admin/member/list/ajax_remove_item', { c : c }, function(output){
			if (output.result)
				row.fadeOut(500);
			else
				alert(output.error_msg);
			$('#modal-remove-item').modal('hide');	
		}, 'json');	
	});
</script>